"""
common patterns for decorators are :
    argument checking
    caching 
    proxy
    context provider
"""

def mydecorator(function):
    def _mydecorator(*args, **kw):
        res = function(*args , **kw)
        print "mydecorator"
        return res
    return _mydecorator


def mydecorator2(arg1,arg2):
    def _mydecorator2(function):
        def __mydecorator2(*args, **kw):
            # dom some stuff before or after the function gets called
            print arg1,"mydecorator2"
            res = function(*args, **kw)
            return res
        return __mydecorator2
    return _mydecorator2



@mydecorator
@mydecorator2('test',None)
def aa():
    print "bb"

aa()
